package com.yanqu.road.server.cmd.union;

import com.yanqu.road.entity.enums.ePlayerAttrType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.union.cross.CrossUnionProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.AttributeModule;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_PLAYER_MONTH_RANK_GRADE_SYNC_TO_GAME,desc = "商会跨服同步实力评定回本服")
public class CrossMonthRankSyncToGameCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CrossUnionProto.SyncPlayerGradeMsg syncPlayerGradeMsg = CrossUnionProto.SyncPlayerGradeMsg.parseFrom(packet.getBytes());
        if (player == null){
            log.debug("跨服返回实力评定等级时玩家不在线,userId = {}",packet.getPlayerId());
            return;
        }
        player.getModule(AttributeModule.class).setAttribute(ePlayerAttrType.MonthRankGradeCacheLevel,syncPlayerGradeMsg.getGrade());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
